<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    import="ass.beans.*" 
    import="ass.dao.*"
	import="ass.dao.support.*" 
	import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Friends Recommended Movie</title>
</head>
<body>
	<%@ include file="header.html"%>
	<%@ include file="userNavBar.html"%>
		<div align="center">
<form name="form1" method="post" action="">

  <table width="400" border="0">
    <tr>
      <th align="left">Movie</th>
      <th align="left">Rating</th>
      <th align="left">Recommend By</th>
      <td>&nbsp;</td>
    </tr>
    <% 
    String username = (String) session.getAttribute("username");
    UserDAO userDAO = new UserDAOImpl();
    UserBean userBean = userDAO.getUser(username);
    
    UserRecommendMovieDAO userRecommendMovieDAO = new UserRecommendMovieDAOImpl();
    List<MovieBean> movieBeanList = userRecommendMovieDAO.getRecommendedMovieList(username);
    
    
    for (MovieBean movieBean : movieBeanList){
    	out.print("<tr>");
        out.print("<td align='left'><a href='MovieDetail?id="+movieBean.getMovie_id()+"'>"+movieBean.getMovie_title()+"</a></td>");
        out.print("<td align='left'>"+ movieBean.getMovie_rating()+"</td>");
        
        List<UserBean> userBeanList = userRecommendMovieDAO.getRecommenderList(username, movieBean.getMovie_id());
        out.print("<td align='left'>");
        int i =0;
        for (UserBean userBeanRecommender : userBeanList){
        	if (i == 0){
	        	out.print(userBeanRecommender.getUsername());
	        }else {
	        	out.print(", " + userBeanRecommender.getUsername() );
	        }
        	i++;
        }
        out.print("</td>");
        out.print("<td>&nbsp;</td>");
        out.print("</tr>");
    }
    
  /*   out.print("<tr>");
    out.print("<td align='left'><a href=''>Rio</a></td>");
    out.print("<td align='left'>Tom</td>");
    out.print("<td>&nbsp;</td>");
    out.print("</tr>");
    out.print("<tr>");
    out.print("<td align='left'><a href=''>Kungfu Panda</a></td>");
    out.print("<td align='left'>Tom, Jerry</td>");
    out.print("<td>&nbsp;</td>");
    out.print("</tr>"); */
    %>
  </table>
</form>
</div>
</body>
</html>